var usuarioCT;
var passCT;
var servidorCT;
var puertoCT;
var bdCT;

function init(u,p,s,pu,b){
	this.usuarioCT = u;
	this.passCT = p;
	this.servidorCT = s;
	this.puertoCT = pu;
	this.bdCT = b;
	cargarTablas(usuarioCT,passCT,servidorCT,puertoCT,bdCT);
	cargaShowTables();
}

function inicializa_xhrUpdate() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function cargaShowTables() {
	cargaShow = inicializa_xhrUpdate();
	if (cargaShow) {
		cargaShow.onreadystatechange = showTables;
		cargaShow.open("POST", path + "/showTablesAjax", true);
		cargaShow.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		cargaShow.send("bd=" + bdCT + "&usuario=" + usuarioCT + "&pass=" + passCT + "&servidor=" + servidorCT + "&puerto=" + puertoCT );
	}
}

function showTables() {
	if (cargaShow.readyState == 4) {
		if (cargaShow.status == 200) {
			document.getElementById('select-tablas').innerHTML = cargaShow.responseText;
			document.getElementById('submit').disabled = false;
		}
	}
}
